package easy.id_701_800;

public class Lee796 {
    public static void main(String[] args) {
        String s = "abcde", goal = "cdeab";
        System.out.println(rotateString(s, goal));
    }
    public static boolean rotateString(String s, String goal) {
        // 处理两种特殊情况
        if(s.equals(goal)) return true; //
        if(s.length() != goal.length()) return false;

        for(int i=0;i<s.length();i++){
            if(s.charAt(i)==goal.charAt(0)){
                int j=0;
                while(j<goal.length() && i+j<s.length() && goal.charAt(j)== s.charAt(i+j)){
                    j++;
                }
                String SubGoal=goal.substring(j);
                String SubS=s.substring(0,i);
                if(SubGoal.equals(SubS)) return true;
            }
        }
        return false;
    }
}
